package com.hongyuan.sellfitness.ui.person.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProviders;

import com.hongyuan.sellfitness.R;
import com.hongyuan.sellfitness.base.AppViewModelFactory;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.CustomFragment;
import com.hongyuan.sellfitness.databinding.FragmentLessonRecordBinding;
import com.hongyuan.sellfitness.ui.person.view_mode.LessonRecordViewModel;

import me.tatarka.bindingcollectionadapter2.BR;

public class LessonRecordFragment extends CustomFragment<FragmentLessonRecordBinding, LessonRecordViewModel> {

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_lesson_record;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public LessonRecordViewModel initViewModel() {
        //使用自定义的ViewModelFactory来创建ViewModel，如果不重写该方法，则默认会调用NetWorkViewModel(@NonNull Application application)构造方法
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this, factory).get(LessonRecordViewModel.class);
    }

    @Override
    public void initView() {
        super.initView();
        setOnRefresh(binding.refresh,REFRESH_0X3);
        setEnableLoadMore(Constants.GET_MEMBER_APPOINTMENT_COURSE_PRIVITE_LIST);
        setEnableRefresh(Constants.GET_MEMBER_APPOINTMENT_COURSE_PRIVITE_LIST);
    }

    @Override
    public void initData() {
        super.initData();

        viewModel.clearParams().setParams("state_str","3")
                .setParams("is_evaluation","0");
                //.setParams("os_id",viewModel.userToken.getOs_id());
        viewModel.requestData(Constants.GET_MEMBER_APPOINTMENT_COURSE_PRIVITE_LIST);
    }

}
